﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PhantomDb.Examples;
using PhantomDb.Examples.Cruds;
using PhantomDb.Examples.Map;

namespace PhantomDb.WF.Example
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                new PhantomDb.Config.App.PhantomAppConfig().Configure();

                var usersCrud = C<UsersCrud>.Get();
                var banksCrud = C<BanksCrud>.Get();

                var users = usersCrud.List();
                var banks = banksCrud.List(Bank.T.Enabled + "=1");

                listBox1.DataSource = users;
                listBox1.DisplayMember = "Name";
                listBox2.DataSource = banks;
                listBox2.DisplayMember = "Name";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                label1.Text = "Por favor, verifique que ha instalado la base de datos (database.sql).";
            }
        }
    }
}
